package com.sto.stoapp.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sto.stoapp.activity.R;
import com.sto.stoapp.dataprocess.parcelable.GetTableParcel;
import com.sto.stoapp.dataprocess.parcelable.SelectTableParcel;

public class ProvinceTableAdapter extends BaseAdapter{
	
	private List<GetTableParcel> courierList;

	private Context context;


	/**
	 * 构造函数
	 * 
	 * @param context
	 * @param courierList
	 */
	public ProvinceTableAdapter(Context context,
			List<GetTableParcel> courierList, SelectTableParcel Entity) {
		this.courierList = courierList;
		this.context = context;
	}

	@Override
	public int getCount() {
		return courierList == null ? 0 : courierList.size();
	}

	@Override
	public Object getItem(int arg0) {
		return courierList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		Holder holder;
		if (view == null) {
			holder = new Holder();
			view = LayoutInflater.from(context).inflate(
					R.layout.sto_select_table_list, null);
			holder.courierCode = (TextView) view
					.findViewById(R.id.courier_code);
			holder.courierCode.setVisibility(View.GONE);
			
			holder.courierName = (TextView) view
					.findViewById(R.id.courier_name);
			view.setTag(holder);
		} else {
			holder = (Holder) view.getTag();
		}
//		holder.courierCode.setText(courierList.get(position).getSelectCode());
		holder.courierName.setText(courierList.get(position).getSelectCode());
		return view;
	}

	class Holder {
		TextView courierCode;
		TextView courierName;
	}
}
